package neca.tmazo.persistencia;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;



public class MySqlManager {

	public static int USE_SERVER=0;
	private static String DRIVER_CLASS_NAME = "com.mysql.jdbc.Driver";
	
	//Servidor 1 (De pago, IP restringida)
	private static String DRIVER_URL = "jdbc:mysql://host203.hostmonster.com/enjuanes_neca_db";
	private static String USER = "enjuanes_neca";
	private static String PASSWORD = "5NecaBest!";
	
	//Servidor 2 (Gratis, lento, IP sin restriccion)
	private static String DRIVER_URL_2 = "jdbc:mysql://db4free.net:3306/tmazo";
	private static String USER_2 = "neca";
	private static String PASSWORD_2 = "psmola";
	
	static {
		
		try {
			Class.forName(DRIVER_CLASS_NAME);
		} catch (ClassNotFoundException e) {
			e.printStackTrace(System.err);
		}
		
	}

	private MySqlManager() {}
	
	public final static Connection getConnection() throws SQLException {
		switch(USE_SERVER)
		{
		case 0:
			return DriverManager.getConnection(DRIVER_URL, USER, PASSWORD);
		case 1:
		default:
			return DriverManager.getConnection(DRIVER_URL_2, USER_2, PASSWORD_2);
		}
	}

}
